import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class AnimatedAnimatedPaddingPage extends StatefulWidget {
  const AnimatedAnimatedPaddingPage({super.key});

  @override
  State<AnimatedAnimatedPaddingPage> createState() => _Animated2PageState();
}

class _Animated2PageState extends State<AnimatedAnimatedPaddingPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Animated')),
      body: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  bool flag = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        child: const Icon(Icons.add),
        onPressed: () {
          setState(() {
            flag = !flag;
          });
        },
      ),
      body: AnimatedPadding(
        curve: Curves.bounceInOut,///插值曲线
        padding: EdgeInsets.fromLTRB(10, flag?10:400, 0, 0),
        duration:  Duration(seconds: 4),
        child: Container(width: 100, height: 100, color: Colors.red),
      ),
    );
  }
}
